package ch.dungegondefenders.appstates;

import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.input.KeyEvent;
import javafx.scene.layout.GridPane;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import javafx.scene.text.Text;
import ch.dungegondefenders.DFConsts;

/**
 * AppState for the menu.<br>
 * The user can choose the file(s) to parse and generate the TagCloud<br>
 */
public class AppStateMenu extends AbstractAppState {
	private GridPane root;

	public AppStateMenu(AppStateManager manager) {
		super(manager);
	}

	@Override
	public Scene createScene() {
		root = new GridPane();
		Scene scene = new Scene(root, DFConsts.SCREEN_X, DFConsts.SCREEN_Y,
				true);
		scene.setFill(Color.GOLD);

		createUI();

		return scene;
	}

	/**
	 * create menu controls
	 */
	private void createUI() {
		// dummy text
		Text txt = new Text("Menu");
		txt.setFont(new Font(30));
		txt.setTranslateX(DFConsts.SCREEN_X / 2);
		txt.setTranslateY(DFConsts.SCREEN_Y / 2);

		root.getChildren().add(txt);
	}

	@Override
	public void activate() {

	}

	@Override
	public void exit() {

	}

	@Override
	public void init() {
		super.init();
		// any key switches to main
		scene.setOnKeyPressed(new EventHandler<KeyEvent>() {
			public void handle(KeyEvent event) {
				manager.switchTo(AppStates.MAIN);
			}
		});
	}
}
